package util;

import core.Player;

public class PlayerCatalog {
	
	private static PlayerCatalog singleton;
	
	private ResourceManager myResources;

	private NameSet<Player> myPlayers = new NameSet<Player>();
	
	public PlayerCatalog()
	{
		myResources = new ResourceManager(this);
		for (String key : myResources)
		{
			Player tmp = (Player) Reflection.createInstance(myResources.getString(key), key);
			if (tmp != null)
				register(tmp);
		}
		singleton = this;
	}
	
	public void register(Player p)
	{
		myPlayers.add(p);
	}
	
	public Player lookup(String name)
	{
		return myPlayers.get(name);
	}
	
	public static PlayerCatalog getSingleton()
	{
		if (singleton == null)
			singleton = new PlayerCatalog();
		return singleton;
	}
}
